<?php
/**
 * 功能描述：	系统日志管理
 * @datetime	2022-07-12
 * @version   	v2.3
 * @author   	ZHL
 * @copyrigh  	2022 ZHL 版权所有
 */

class Admin_SyslogController extends Controller {

    // 是否登录
    function __construct($controller, $action) {
        parent::__construct($controller, $action);
        $loginSer = new Admin_LoginServe();
        $loginSer->judgeSessionLogin($controller, $action);
    }

    /**
     * Notes:index
     */
    function index(){
        SYS_REDIRECT('admin_syslog_login');
    }

    /**
     * Notes:操作日志
     */
    public function act(){
        $commonC = new Admin_CommonController();
        $commonC->lists('syslog_act', 'admin_syslog/act', '操作日志列表', '');
    }

    /**
     * Notes:登录日志
     */
    public function login(){
        $commonC = new Admin_CommonController();
        $commonC->lists('syslog_login', 'admin_syslog/login', '登录日志列表', '');
    }

    /**
     * Notes:日志导出Execl表格
     * User: ZhuHaili
     */
    function execl(){
        $pageNo = Fun::input('p', 0, 'd');
        $idStr = Fun::input('i');
        $search = Fun::input('search');
        $orderby = Fun::input('o'); //排序例如：a.id_desc,a.viewseq_desc
        $mouldCode = Fun::input('m');
        if($orderby){$orderby = strtr($orderby, '_', " ");} // 替换字符串
        // 获取数据
        $commC = new Admin_CommonController();
        if(!$mouldCode){
            htmlAlert('请指定要导出的日志类型');
        }
        $fileTitle = '日志';
        $thList['user_id'] = '用户ID';
        $thList['title'] = '用户';
        if($mouldCode == 'syslog_act'){
            $fileTitle = '操作日志';
            $thList['mould_code'] = '操作模型';
            $thList['menu_id'] = '操作菜单ID';
            $thList['menu_name'] = '操作菜单';
            $thList['essay_id'] = '操作文章ID';
            $thList['content'] = '操作内容';
            $thList['typestxt'] = '操作类型';
            $thList['statustxt3'] = '状态';
        }else if($mouldCode == 'syslog_login'){
            $fileTitle = '登录日志';
            $thList['user_mobile'] = '手机';
            $thList['user_email'] = '邮箱';
            $thList['ip'] = 'IP';
            $thList['statustxt3'] = '状态';
        }
        $result = $commC->getListExecl($mouldCode, $pageNo,$idStr, $search, $thList, $orderby);
        // 导出execl
        $fileTitle = $fileTitle.'_'.date('Ymd-His'); // execl文件名
        $e = array('id'); // 屏蔽科学计数法字段
        $csv = new ManageCSV();
        $csv->export($result['trList'], $result['thList'], $fileTitle, $e);
    }

    /**
     * Notes:日志删除
     * User: ZHL
     * Date: 2022/7/18
     */
    public function del(){
        $commC = new Admin_CommonController();
        $commC->del();
    }

    /**
     * Notes:批量删除
     * User: ZHL
     * Date: 2022/7/18
     */
    public function dels(){
        $commC = new Admin_CommonController();
        $commC->dels();
    }

    /**
     * Notes:批量修改状态
     * User: ZhuHaili
     */
    public function status(){
        $commC = new Admin_CommonController();
        $commC->status();
    }

}